package com.ruoyi.web.tdmdata.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.tdmdata.domain.TdmYaoYongZhiWu;
import com.ruoyi.web.tdmdata.service.ITdmYaoYongZhiWuService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 药用植物Controller
 * 
 * @author ly
 * @date 2022-03-14
 */
@RestController
@RequestMapping("/tdmdata/TdmYaoYongZhiWu")
public class TdmYaoYongZhiWuController extends BaseController
{
    @Autowired
    private ITdmYaoYongZhiWuService tdmYaoYongZhiWuService;

    /**
     * 查询药用植物列表
     */
    //  @PreAuthorize("@ss.hasPermi('tdmdata:TdmYaoYongZhiWu:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmYaoYongZhiWu tdmYaoYongZhiWu)
    {
        startPage();
        List<TdmYaoYongZhiWu> list = tdmYaoYongZhiWuService.selectTdmYaoYongZhiWuList(tdmYaoYongZhiWu);
        return getDataTable(list);
    }

    /**
     * 导出药用植物列表
     */
    // @PreAuthorize("@ss.hasPermi('tdmdata:TdmYaoYongZhiWu:export')")
    @Log(title = "药用植物", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmYaoYongZhiWu tdmYaoYongZhiWu)
    {
        List<TdmYaoYongZhiWu> list = tdmYaoYongZhiWuService.selectTdmYaoYongZhiWuList(tdmYaoYongZhiWu);
        ExcelUtil<TdmYaoYongZhiWu> util = new ExcelUtil<TdmYaoYongZhiWu>(TdmYaoYongZhiWu.class);
        util.exportExcel(response, list, "药用植物数据");
    }

    /**
     * 获取药用植物详细信息
     */
    // @PreAuthorize("@ss.hasPermi('tdmdata:TdmYaoYongZhiWu:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tdmYaoYongZhiWuService.selectTdmYaoYongZhiWuById(id));
    }

    /**
     * 新增药用植物
     */
    //@PreAuthorize("@ss.hasPermi('tdmdata:TdmYaoYongZhiWu:add')")
    @Log(title = "药用植物", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmYaoYongZhiWu tdmYaoYongZhiWu)
    {
        return toAjax(tdmYaoYongZhiWuService.insertTdmYaoYongZhiWu(tdmYaoYongZhiWu));
    }

    /**
     * 修改药用植物
     */
    // @PreAuthorize("@ss.hasPermi('tdmdata:TdmYaoYongZhiWu:edit')")
    @Log(title = "药用植物", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmYaoYongZhiWu tdmYaoYongZhiWu)
    {
        return toAjax(tdmYaoYongZhiWuService.updateTdmYaoYongZhiWu(tdmYaoYongZhiWu));
    }

    /**
     * 删除药用植物
     */
    // @PreAuthorize("@ss.hasPermi('tdmdata:TdmYaoYongZhiWu:remove')")
    @Log(title = "药用植物", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdmYaoYongZhiWuService.deleteTdmYaoYongZhiWuByIds(ids));
    }
}
